package com.jie.eclipse.pan.popup.wizardpage;

import java.util.Map;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;

import com.jie.eclipse.pan.bind.BaseDataBind;
import com.jie.eclipse.pan.bind.PageDataBind;
import com.jie.eclipse.pan.config.BasePageConfig;
import com.jie.eclipse.pan.dao.QMDao;
import com.jie.eclipse.pan.data.BaseDataEntity;
import com.jie.eclipse.pan.popup.wizard.BaseWizard;

public class BasePage extends WizardPage{
	private BaseWizard baseWizard = null;
	private BaseDataBind dataBind = null;//数据绑定
	private BaseDataEntity tempDate = null;//对话框默认数据
	private BasePage prePage = null; 
	protected Map<String,BasePage> secPageMap = null;
	
	public BasePage(String pageName) {
		super(pageName);
		this.dataBind = new PageDataBind();
	}
	
	protected BasePage(String pageName, String title, ImageDescriptor titleImage) {
		super(pageName, title, titleImage);
		this.dataBind = new PageDataBind();
	}

	@Override
	public void performHelp() {
		MessageDialog.openInformation(Display.getCurrent().getActiveShell(),"帮助","请联系颜杰,email:linuxnet@163.com");
	}

	public void createControl(Composite arg0) {
		
	}
	
	public BaseDataBind getDataBind() {
		return dataBind;
	}
	
	public BaseDataBind getNewDataBind() {
		return new PageDataBind();
	}

	public void setDataBind(BaseDataBind dataBind) {
		this.dataBind = dataBind;
	}
	
	/**
	 * @return
	 */
	public BaseWizard getBaseWizard() {
		return this.baseWizard;
	}
	
	public void setBaseWizard(BaseWizard baseWizard) {
		this.baseWizard = baseWizard;
	}
	
	/**
	 * 重新加载页面配置
	 */
	public void reloadPageConfig(){
		BasePageConfig pageConfig = this.getBaseWizard().getPageConfig();
		pageConfig.loadConfig(this.getDataBind().getRecord());
	}
	public BasePage getPrePage() {
		return prePage;
	}

	public void setPrePage(BasePage prePage) {
		this.prePage = prePage;
	}
	
	public BasePage getNxtPage() {
		return null;
	}
	
	public QMDao getQmDao(){
		return QMDao.getInstance();
	}
	
	public BaseDataEntity getDataInstance(){
		if(this.tempDate == null){
			this.tempDate = new BaseDataEntity();
		}
		return this.tempDate;
	}
}
